package com.example.qxfw.nyqx.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.zy.AgriProduct;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.util.List;

@Mapper
@DS("service")
public interface AgriProductMapper extends BaseMapper<AgriProduct> {

    Integer selectId(@Param("productName") String productName, @Param("productType") String productType, @Param("forecastTime") Timestamp forecastTime, @Param("makeTime") Timestamp makeTime, @Param("maker") String maker);

    @Select("select id " +
            "from agri_product " +
            "where productName='${productName}' and productType='${productType}' and forecastTime='${forecastTime}' and maker='${maker}'")
    Integer selectId1(@Param("productName") String productName, @Param("productType") String productType, @Param("forecastTime") Timestamp forecastTime, @Param("maker") String maker);

    int insert(@Param("agriProduct") AgriProduct agriProduct);

    List<AgriProduct> selectIdByProducttype(@Param("productType") String type);

    @Delete("delete " +
            "from agri_product "+
            "where id='${id}'")
    int deleteById(@Param("id") int id);


}
